﻿@{
    IList<long> userIds = ViewData.Get<IList<long>>("userIds", null);
    PointCategory experiencePoints = ViewData.Get<PointCategory>("experiencePoints", null);
    PointCategory reputationPoints = ViewData.Get<PointCategory>("reputationPoints", null);
    PointCategory tradePoints = ViewData.Get<PointCategory>("tradePoints", null);

}
<div class="tnc-reward-users">
    @Html.StatusMessage()
    @using (Html.BeginAjaxForm("_RewardUsers", "ControlPanelUser", null, FormMethod.Post, new AjaxFormOptions { OnErrorCallBack = "OnErrorCallBack", OnSuccessCallBack = "OnSuccessCallBack" }, new RouteValueDictionary { { "Id", "rewardUsers" } }))
    {
        <div class="tnc-dailog-pd">
            <div class="tn-form-box">
                <div class="tn-text-heading tn-border-gray tn-border-bottom"><span class="tn-text-note">提示：同级管理员无法互相奖惩</span></div>
                <table>
                    <tr>
                        <th>选择用户：</th>
                        <td>
                            <div id="selectUsers">
                                @Html.UserSelector("UserId", 20, userIds, SelectorWidthType.Long, UserSelectorSearchScope.Site, false)
                            </div>
                            <div id="manual">
                                @Html.TextArea("NickName", new { @class = "tn-textarea tn-input-long tn-border-gray" })
                                <div class="tn-explain"><span class="tn-text-note">输入显示名称并以中文逗号隔开</span></div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th></th>
                        <td>
                            <input class="tn-radiobutton" type="checkbox" value="false" name="enter" id="enter" />
                            <label for="enter"> 手动录入</label>
                        </td>
                    </tr>
                    <tr>
                        <th>操作：</th>
                        <td>
                            <ul class="tn-radiobutton-list">
                            <li>
                                <input class="tn-radiobutton" type="radio" value="true" checked="checked" name="isIncome" id="isIncome" />
                                <label for="isIncome">
                                    奖励</label>
                            </li>
                            <li>
                                <input class="tn-radiobutton" type="radio" value="false" name="isIncome" id="notIncome" />
                                <label for="notIncome">
                                    处罚</label>
                            </li>
                        </ul>
                        </td>
                    </tr>
                    <tr>
                        <th>@experiencePoints.CategoryName：</th>
                        <td>
                            <input class="tn-textbox tn-border-gray" type="text" value="0" name="experiencePoints" id="experiencePoints" />
                        </td>
                    </tr>
                    <tr>
                        <th>@reputationPoints.CategoryName：</th>
                        <td>
                            <input class="tn-textbox tn-border-gray" type="text" value="0" name="reputationPoints" id="reputationPoints" />
                        </td>
                    </tr>
                    <tr>
                        <th>@tradePoints.CategoryName：</th>
                        <td>
                            <input class="tn-textbox tn-border-gray" type="text" value="0" name="tradePoints" id="tradePoints" />
                        </td>
                    </tr>
                    <tr>
                        <th>理由：</th>
                        <td>
                            <input class="tn-textbox tn-border-gray" type="text" name="description" />
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="tnc-artdilog-btn tn-border-gray tn-border-top tn-bg-gray">
            @Html.Button("确定", ButtonTypes.Submit, HighlightStyles.Primary, htmlAttributes: new { id = "rewardAndPunishmentButton" })
            @Html.Button("取消", ButtonTypes.Cancel, HighlightStyles.Secondary, htmlAttributes: new { dialogOperation = "close" })
        </div>
    }
</div>
<script type="text/dialog">    
      this.title("奖惩用户");    
</script>
<script type="text/javascript" language="javascript">
    function OnSuccessCallBack(data) {
        art.dialog.tips(data.MessageContent, 1.5, data.MessageType, function () { window.location.reload(true); });
    }
    $(document).ready(function () {
        $("#rewardAndPunishmentButton").click(function () {
            if (!$("#rewardUsers").valid())
                return false;
        });

        $("#rewardUsers").validate({
            rules: {
                experiencePoints: {
                    required: true,
                    digits: true,
                    maxlength: 5,
                    min: 0
                },

                reputationPoints: {
                    required: true,
                    digits: true,
                    maxlength: 5,
                    min: 0
                },
                tradePoints: {
                    required: true,
                    digits: true,
                    maxlength: 5,
                    min: 0
                }

            },
            messages: {
                experiencePoints: {
                    required: "请填写数值",
                    digits: "请填写0-99999之间的整数",
                    maxlength: "请填写0-99999之间的整数",
                    min: "请填写0-99999之间的整数"
                },
                reputationPoints: {
                    required: "请填写数值",
                    digits: "请填写0-99999之间的整数",
                    maxlength: "请填写0-99999之间的整数",
                    min: "请填写0-99999之间的整数"
                },
                tradePoints: {
                    required: "请填写数值",
                    digits: "请填写0-99999之间的整数",
                    maxlength: "请填写0-99999之间的整数",
                    min: "请填写0-99999之间的整数"
                }

            }

        });

        //忽略手动输入
        //        $("#shoudong2").addClass("ignore");
        $("#manual").hide();
        //判断是否手动输入
        $("#enter").click(function () {
            if ($(this).attr("checked")) {
                $("#selectUsers").hide().addClass("ignore");
                $("#manual").show().removeClass("ignore");
            } else {
                $("#selectUsers").show().removeClass("ignore");
                $("#manual").hide().addClass("ignore");
            }
        });

    });


</script>
